<?php
    require_once( '../includes/common.inc.php' );
    
    $isAllVarsExist = isset( $_GET['file_name'] )  && isset( $_GET['change_rating'] ) &&
                      !empty( $_GET['file_name'] ) && !empty( $_GET['change_rating'] );
    if ( $isAllVarsExist )
    {
        $ratingChanger = new RatingChanger();
        try
        {
            echo $ratingChanger->change( $_GET['file_name'], $_GET['change_rating'] );
        }
        catch ( Exception $e )
        {
            if ( $e->getMessage() != 'already used' )
            {
                echo 'error';
            }
            else
            {
                echo $e->getMessage();
            }
        }
    }
?>